<?php
	$email = $this->common_model->getone('users', array('id'=>$data->user_id))->email;
	$gift = $this->common_model->getone('gift', array('id'=>$data->gift_id))->name;
	$date = date("d/m/Y", time());
?>
<script>
$(document).ready(function(){
	$("#status").change(function(){
	  var str = $(this).val();
	  if(str != <?php echo $data->status;?>){
		  if(str == 0){
		  	$("#hidden").html('<input type="hidden" name="cancel_date" value="<?php echo $date;?>">');
		  }
		  else if(str == 1){
		  	$("#hidden").html('<input type="hidden" name="order_date" value="<?php echo $date;?>">');
		  }
		  else if(str == 2){
		  	$("#hidden").html('<input type="hidden" name="ship_date" value="<?php echo $date;?>">');
		  }
		  else if(str == 3){
		  	$("#hidden").html('<input type="hidden" name="delivery_date" value="<?php echo $date;?>">');
		  }
	  }
	  else{
		  $("#hidden").html('');
	  }
	}).change();
});
</script>
<div id="main-content">
    <div class="container">
    	<div class="row">
    		<div id="content" class="col-lg-12">
    			<!-- PAGE HEADER-->
    			<div class="row">
    				<div class="col-sm-12">
                        <div class="page-header">
    						<div class="clearfix">
    							<h3 class="content-title pull-left">Sửa phần thưởng</h3>
    						</div>
    						<div class="description">Xin mời nhập theo mẫu bên dưới</div>
   					    </div>
   				     </div>
    			</div>
                <!-- DATA TABLES -->
						<div class="row">
							<div class="col-md-12">
								<!-- BOX -->
								<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>Chi tiết phần thưởng</h4>
										<div class="tools hidden-xs">
											<a href="javascript:;" data-toggle="tooltip" title="Ẩn đi" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
										</div>
									</div>
									<div class="box-body">
                                        <!-- Start Form -->
                                         <?php echo validation_errors(); ?>
                                        <form method="POST" class="form-horizontal row-border" action="<?php echo base_url().'admin/xuly/exchange/list/'.$this->uri->segment(5);?>">
										  <div id="hidden"></div>
										  <div class="form-group">
											 <label class="col-md-2 control-label">Email người gửi :</label> 
											 <div class="col-md-10"><input disabled name="email" id="email" type="text" value="<?php if(!empty($data)){echo $email;};?>" class="form-control" /></div>
                                          </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Phần thưởng :</label> 
											 <div class="col-md-10"><input disabled id="gift" name="gift" value="<?php if(!empty($data)){echo $gift;};?>" type="text" class="form-control" /></div>
										  </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Ngày yêu cầu :</label> 
											 <div class="col-md-10"><input disabled id="order_date" name="order_date" value="<?php if(!empty($data)){echo $data->order_date;};?>" type="text" class="form-control" /></div>
										  </div>
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Thông tin nhận phần thưởng :</label> 
											 <div class="col-md-10">Họ và tên: <b><?php echo $data->name;?></b><br/>Ngày sinh: <b><?php echo $data->birthday;?></b><br/>Địa chỉ: <b><?php echo $data->address.', '.$data->district.', '.$data->province;?></b><br/>Điện thoại: <b><?php echo $data->phone;?></b></div>
										  </div>                                 
                                          <div class="form-group">
											 <label class="col-md-2 control-label">Trạng thái:</label> 
											 <div class="col-md-10">
                                                <select name="status" id="status" class="form-control">
                                                <option <?php if(!empty($data)){if($data->status==0)echo 'selected="selected"';} ?> value='0'>Đã hủy bỏ</option> 
                                                <option <?php if(!empty($data)){if($data->status==1)echo 'selected="selected"';} ?> value='1'>Đã yêu cầu</option> 
                                                <option <?php if(!empty($data)){if($data->status==2)echo 'selected="selected"';} ?> value='2'>Đã gửi quà</option> 
                                                <option <?php if(!empty($data)){if($data->status==3)echo 'selected="selected"';} ?> value='3'>Đã nhận quà</option> 
                                                </select>
                                             </div>
										  </div>
                                          <div class="form-group">
													 <label class="col-md-2 control-label">Nội dung:</label> 
													 <div class="col-md-10"><textarea rows="3" cols="5" id="soanthao" name="desc" class="form-control"><?php if(!empty($data)){echo $data->desc;};?></textarea></div>
										  </div>
                                          <input class="guidulieu btn btn-success" type="submit" value="Lưu"/>
										</form>
                                        <!-- End Form -->
                                    </div>
								</div>
								<!-- /BOX -->
							</div>
						</div>
						<!-- /DATA TABLES -->
    			<!-- /PAGE HEADER -->
    		</div>
    	</div>
    </div>
</div>
<script type="text/javascript">
           if ( typeof CKEDITOR == 'undefined' )
            {
            	document.write("khong ");
            }
            else
            {
            	var editor = CKEDITOR.replace( 'soanthao' );   
                CKFinder.setupCKEditor( editor, '<?php echo base_url();?>ckeditor/ckfinder/' ) ;  
            }
		</script>